package ru.ncedu.java.vlku.hrs.uil.cmd;

import ru.ncedu.java.vlku.hrs.bll.HRSManager;
import ru.ncedu.java.vlku.hrs.bll.HRSManagerFactory;
import ru.ncedu.java.vlku.hrs.model.Shop;

public class UpdateShop implements Command {
    // update shop <id> <new_name> <new_address>
    @Override
    public void execute( String[] args ) {
        if (args.length != 5)
            throw new IllegalArgumentException();
        HRSManager manager = HRSManagerFactory.getInstance().getHRSManager();
        Long id = Long.parseLong(args[2]);
        Shop shop = manager.getShopById(id);
        shop.setName(args[3]);
        shop.setAddress(args[4]);
        manager.updateShop(shop);
    }
}
